package dyyx;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@Scope("prototype")
public class HelloController {


	private static final String VERSION = "spring-cloud-provider-2019-05-16 18:15";

	@GetMapping(value = "/status")
    public String status() throws Exception {
        return VERSION;
    }
	
    @GetMapping(value = "/hello")
    public String hello() throws Exception {
        return "hello spring cloud provider,"+new Date();
    }
    
    
    @GetMapping(value = "/serverInfo")
    public Map<String,Object> serverInfo(HttpServletRequest request) throws Exception {
    	Map<String,Object> map = new HashMap<String,Object>();
    	map.put("version", VERSION);
    	map.put("ip", HostInfoUtil.getHostInfo());
    	
    	map.put("now", new Date()+"");
    	
    	map.put("webroot", request.getRealPath("/"));
    	
    	map.put("serverPort", AppConfigUtil.getPort());


    	return map; 	
    }
    
    
    
    
    
}